package net.monare.mifss;

import net.monare.mifss.lib.AppContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

@Component

public class MifssMessages {

    @Autowired
    private transient ApplicationContext applicationContext;

    public static String getMessage(String messageLabel) {
        return getMessageSource().getMessage(messageLabel, null, LocaleContextHolder.getLocale());
    }

    private static MessageSource getMessageSource() {

        return (MessageSource) AppContext.getApplicationContext().getBean("messageSource");

    }
}
